/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.DealManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class AddDealCustomer extends AbstractAction
/*    */ {
/*    */   public AddDealCustomer(AbstractHttpServlet servlet)
/*    */   {
/* 25 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 31 */     response.setContentType("text/html;charset=utf-8");
/* 32 */     PrintWriter out = response.getWriter();
/* 33 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 35 */     User loginUser = super.getLoginUser(request);
/* 36 */     int dealId = Util.getURLIntParameter(request.getParameter("DealId"));
/* 37 */     int customerId = Util.getURLIntParameter(request
/* 38 */       .getParameter("CustomerId"));
/* 39 */     String customerName = Util.getURLParameter(request
/* 40 */       .getParameter("CustomerName"));
/* 41 */     int customerType = Util.getURLIntParameter(request
/* 42 */       .getParameter("CustomerType"));
/* 43 */     int primaryFlag = 0;
/* 44 */     int companyId = loginUser.companyId;
/*    */ 
/* 46 */     DealManager manager = new DealManager();
/*    */     try {
/* 48 */       int result = manager.addDealCustomer(dealId, customerId, 
/* 49 */         customerName, customerType, primaryFlag, companyId);
/* 50 */       if (result == 1) {
/* 51 */         jsonObject.put("error", "0");
/*    */       } else {
/* 53 */         jsonObject.put("error", "1");
/* 54 */         jsonObject.put("msg", "该关联者已经添加");
/*    */       }
/*    */     } catch (DBException e) {
/* 57 */       e.printStackTrace();
/* 58 */       jsonObject.put("error", "1");
/*    */     } catch (SQLException e) {
/* 60 */       e.printStackTrace();
/* 61 */       jsonObject.put("error", "1");
/*    */     }
/* 63 */     out.println(jsonObject);
/* 64 */     out.flush();
/* 65 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.AddDealCustomer
 * JD-Core Version:    0.6.1
 */